
#include "contract.h"

#include "ledId.h"
#include "IO.h"

#include "BSP_Config.h"

#define LED_LEVEL_OFF	0u
#define LED_LEVEL_ON	(! LED_LEVEL_OFF)

static const IO_T LEDs[LedId_Limit] = {
//	[LedId_Blue ] = IO_INIT_TABLE(LED_B_GP, LED_B_PIN),
	[LedId_Greent ] = IO_INIT_TABLE(LED_G_GP, LED_G_PIN),
	[LedId_White ] = IO_INIT_TABLE(LED_W_GP, LED_W_PIN),
//	[LedId_Red ] = IO_INIT_TABLE(LED_R_GP, LED_R_PIN),
};


uint8_t BSP_Led_GetState(uint8_t LedId){
	REQUIRE(LedId < LedId_Limit);
	
	if(LedId < LedId_Limit){
		return IO_Get(&LEDs[LedId]) == LED_LEVEL_ON ? Led_S_ON : Led_S_OFF;
	}
	return Led_S_OFF;
}

void BSP_Led_SetState(uint8_t id, uint8_t state){
	REQUIRE(id < LedId_Limit);
	if(id < LedId_Limit){
		IO_Set(&LEDs[id], state ? LED_LEVEL_ON : LED_LEVEL_OFF);
	}
}

void BSP_Led_Init(void){
	uint8_t i;
	for(i = 0; i < LedId_Limit; i++){
	    IO_Init(&LEDs[i], IO_Mode_OUT);
		IO_Set(&LEDs[i], LED_LEVEL_OFF);
    }
}



